1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Label;
26 
27 private import gio.MenuModel;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import glib.c.functions;
31 private import gobject.ObjectG;
32 private import gobject.Signals;
33 private import gtk.Widget;
34 private import gtk.c.functions;
35 public  import gtk.c.types;
36 private import pango.PgAttributeList;
37 private import pango.PgLayout;
38 private import std.algorithm;
39 
40 
41 /**
42  * The `GtkLabel` widget displays a small amount of text.
43  * 
44  * As the name implies, most labels are used to label another widget
45  * such as a [class@Button].
46  * 
47  * ![An example GtkLabel](label.png)
48  * 
49  * # CSS nodes
50  * 
51  * ```
52  * label
53  * ├── [selection]
54  * ├── [link]
55  * ┊
56  * ╰── [link]
57  * ```
58  * 
59  * `GtkLabel` has a single CSS node with the name label. A wide variety
60  * of style classes may be applied to labels, such as .title, .subtitle,
61  * .dim-label, etc. In the `GtkShortcutsWindow`, labels are used with the
62  * .keycap style class.
63  * 
64  * If the label has a selection, it gets a subnode with name selection.
65  * 
66  * If the label has links, there is one subnode per link. These subnodes
67  * carry the link or visited state depending on whether they have been
68  * visited. In this case, label node also gets a .link style class.
69  * 
70  * # GtkLabel as GtkBuildable
71  * 
72  * The GtkLabel implementation of the GtkBuildable interface supports a
73  * custom <attributes> element, which supports any number of <attribute>
74  * elements. The <attribute> element has attributes named “name“, “value“,
75  * “start“ and “end“ and allows you to specify [struct@Pango.Attribute]
76  * values for this label.
77  * 
78  * An example of a UI definition fragment specifying Pango attributes:
79  * ```xml
80  * <object class="GtkLabel">
81  * <attributes>
82  * <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
83  * <attribute name="background" value="red" start="5" end="10"/>
84  * </attributes>
85  * </object>
86  * ```
87  * 
88  * The start and end attributes specify the range of characters to which the
89  * Pango attribute applies. If start and end are not specified, the attribute is
90  * applied to the whole text. Note that specifying ranges does not make much
91  * sense with translatable attributes. Use markup embedded in the translatable
92  * content instead.
93  * 
94  * # Accessibility
95  * 
96  * `GtkLabel` uses the %GTK_ACCESSIBLE_ROLE_LABEL role.
97  * 
98  * # Mnemonics
99  * 
100  * Labels may contain “mnemonics”. Mnemonics are underlined characters in the
101  * label, used for keyboard navigation. Mnemonics are created by providing a
102  * string with an underscore before the mnemonic character, such as `"_File"`,
103  * to the functions [ctor@Gtk.Label.new_with_mnemonic] or
104  * [method@Gtk.Label.set_text_with_mnemonic].
105  * 
106  * Mnemonics automatically activate any activatable widget the label is
107  * inside, such as a [class@Gtk.Button]; if the label is not inside the
108  * mnemonic’s target widget, you have to tell the label about the target
109  * using [class@Gtk.Label.set_mnemonic_widget]. Here’s a simple example where
110  * the label is inside a button:
111  * 
112  * ```c
113  * // Pressing Alt+H will activate this button
114  * GtkWidget *button = gtk_button_new ();
115  * GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
116  * gtk_button_set_child (GTK_BUTTON (button), label);
117  * ```
118  * 
119  * There’s a convenience function to create buttons with a mnemonic label
120  * already inside:
121  * 
122  * ```c
123  * // Pressing Alt+H will activate this button
124  * GtkWidget *button = gtk_button_new_with_mnemonic ("_Hello");
125  * ```
126  * 
127  * To create a mnemonic for a widget alongside the label, such as a
128  * [class@Gtk.Entry], you have to point the label at the entry with
129  * [method@Gtk.Label.set_mnemonic_widget]:
130  * 
131  * ```c
132  * // Pressing Alt+H will focus the entry
133  * GtkWidget *entry = gtk_entry_new ();
134  * GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
135  * gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
136  * ```
137  * 
138  * # Markup (styled text)
139  * 
140  * To make it easy to format text in a label (changing colors,
141  * fonts, etc.), label text can be provided in a simple
142  * markup format:
143  * 
144  * Here’s how to create a label with a small font:
145  * ```c
146  * GtkWidget *label = gtk_label_new (NULL);
147  * gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");
148  * ```
149  * 
150  * (See the Pango manual for complete documentation] of available
151  * tags, [func@Pango.parse_markup])
152  * 
153  * The markup passed to gtk_label_set_markup() must be valid; for example,
154  * literal <, > and & characters must be escaped as &lt;, &gt;, and &amp;.
155  * If you pass text obtained from the user, file, or a network to
156  * [method@Gtk.Label.set_markup], you’ll want to escape it with
157  * g_markup_escape_text() or g_markup_printf_escaped().
158  * 
159  * Markup strings are just a convenient way to set the [struct@Pango.AttrList]
160  * on a label; [method@Gtk.Label.set_attributes] may be a simpler way to set
161  * attributes in some cases. Be careful though; [struct@Pango.AttrList] tends
162  * to cause internationalization problems, unless you’re applying attributes
163  * to the entire string (i.e. unless you set the range of each attribute
164  * to [0, %G_MAXINT)). The reason is that specifying the start_index and
165  * end_index for a [struct@Pango.Attribute] requires knowledge of the exact
166  * string being displayed, so translations will cause problems.
167  * 
168  * # Selectable labels
169  * 
170  * Labels can be made selectable with [method@Gtk.Label.set_selectable].
171  * Selectable labels allow the user to copy the label contents to
172  * the clipboard. Only labels that contain useful-to-copy information
173  * — such as error messages — should be made selectable.
174  * 
175  * # Text layout
176  * 
177  * A label can contain any number of paragraphs, but will have
178  * performance problems if it contains more than a small number.
179  * Paragraphs are separated by newlines or other paragraph separators
180  * understood by Pango.
181  * 
182  * Labels can automatically wrap text if you call [method@Gtk.Label.set_wrap].
183  * 
184  * [method@Gtk.Label.set_justify] sets how the lines in a label align
185  * with one another. If you want to set how the label as a whole aligns
186  * in its available space, see the [property@Gtk.Widget:halign] and
187  * [property@Gtk.Widget:valign] properties.
188  * 
189  * The [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
190  * properties can be used to control the size allocation of ellipsized or
191  * wrapped labels. For ellipsizing labels, if either is specified (and less
192  * than the actual text size), it is used as the minimum width, and the actual
193  * text size is used as the natural width of the label. For wrapping labels,
194  * width-chars is used as the minimum width, if specified, and max-width-chars
195  * is used as the natural width. Even if max-width-chars specified, wrapping
196  * labels will be rewrapped to use all of the available width.
197  * 
198  * # Links
199  * 
200  * GTK supports markup for clickable hyperlinks in addition to regular Pango
201  * markup. The markup for links is borrowed from HTML, using the `<a>` with
202  * “href“, “title“ and “class“ attributes. GTK renders links similar to the
203  * way they appear in web browsers, with colored, underlined text. The “title“
204  * attribute is displayed as a tooltip on the link. The “class“ attribute is
205  * used as style class on the CSS node for the link.
206  * 
207  * An example looks like this:
208  * 
209  * ```c
210  * const char *text =
211  * "Go to the"
212  * "<a href=\"http://www.gtk.org title=\"&lt;i&gt;Our&lt;/i&gt; website\">"
213  * "GTK website</a> for more...";
214  * GtkWidget *label = gtk_label_new (NULL);
215  * gtk_label_set_markup (GTK_LABEL (label), text);
216  * ```
217  * 
218  * It is possible to implement custom handling for links and their tooltips
219  * with the [signal@Gtk.Label::activate-link] signal and the
220  * [method@Gtk.Label.get_current_uri] function.
221  */
222 public class Label : Widget
223 {
224 	/** the main Gtk struct */
225 	protected GtkLabel* gtkLabel;
226 
227 	/** Get the main Gtk struct */
228 	public GtkLabel* getLabelStruct(bool transferOwnership = false)
229 	{
230 		if (transferOwnership)
231 			ownedRef = false;
232 		return gtkLabel;
233 	}
234 
235 	/** the main Gtk struct as a void* */
236 	protected override void* getStruct()
237 	{
238 		return cast(void*)gtkLabel;
239 	}
240 
241 	/**
242 	 * Sets our main struct and passes it to the parent class.
243 	 */
244 	public this (GtkLabel* gtkLabel, bool ownedRef = false)
245 	{
246 		this.gtkLabel = gtkLabel;
247 		super(cast(GtkWidget*)gtkLabel, ownedRef);
248 	}
249 
250 
251 	/** */
252 	public static GType getType()
253 	{
254 		return gtk_label_get_type();
255 	}
256 
257 	/**
258 	 * Creates a new `GtkLabel`, containing the text in @str.
259 	 *
260 	 * If characters in @str are preceded by an underscore, they are
261 	 * underlined. If you need a literal underscore character in a label, use
262 	 * '__' (two underscores). The first underlined character represents a
263 	 * keyboard accelerator called a mnemonic. The mnemonic key can be used
264 	 * to activate another widget, chosen automatically, or explicitly using
265 	 * [method@Gtk.Label.set_mnemonic_widget].
266 	 *
267 	 * If [method@Gtk.Label.set_mnemonic_widget] is not called, then the first
268 	 * activatable ancestor of the `GtkLabel` will be chosen as the mnemonic
269 	 * widget. For instance, if the label is inside a button or menu item,
270 	 * the button or menu item will automatically become the mnemonic widget
271 	 * and be activated by the mnemonic.
272 	 *
273 	 * Params:
274 	 *     str = The text of the label, with an underscore in front of the
275 	 *         mnemonic character
276 	 *
277 	 * Returns: the new `GtkLabel`
278 	 *
279 	 * Throws: ConstructionException GTK+ fails to create the object.
280 	 */
281 	public this(string str)
282 	{
283 		auto __p = gtk_label_new_with_mnemonic(Str.toStringz(str));
284 
285 		if(__p is null)
286 		{
287 			throw new ConstructionException("null returned by new_with_mnemonic");
288 		}
289 
290 		this(cast(GtkLabel*) __p);
291 	}
292 
293 	/**
294 	 * Gets the labels attribute list.
295 	 *
296 	 * This is the [struct@Pango.AttrList] that was set on the label using
297 	 * [method@Gtk.Label.set_attributes], if any. This function does not
298 	 * reflect attributes that come from the labels markup (see
299 	 * [method@Gtk.Label.set_markup]). If you want to get the effective
300 	 * attributes for the label, use
301 	 * `pango_layout_get_attribute (gtk_label_get_layout (self))`.
302 	 *
303 	 * Returns: the attribute list
304 	 */
305 	public PgAttributeList getAttributes()
306 	{
307 		auto __p = gtk_label_get_attributes(gtkLabel);
308 
309 		if(__p is null)
310 		{
311 			return null;
312 		}
313 
314 		return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) __p);
315 	}
316 
317 	/**
318 	 * Returns the URI for the currently active link in the label.
319 	 *
320 	 * The active link is the one under the mouse pointer or, in a
321 	 * selectable label, the link in which the text cursor is currently
322 	 * positioned.
323 	 *
324 	 * This function is intended for use in a [signal@Gtk.Label::activate-link]
325 	 * handler or for use in a [signal@Gtk.Widget::query-tooltip] handler.
326 	 *
327 	 * Returns: the currently active URI
328 	 */
329 	public string getCurrentUri()
330 	{
331 		return Str.toString(gtk_label_get_current_uri(gtkLabel));
332 	}
333 
334 	/**
335 	 * Returns the ellipsizing position of the label.
336 	 *
337 	 * See [method@Gtk.Label.set_ellipsize].
338 	 *
339 	 * Returns: `PangoEllipsizeMode`
340 	 */
341 	public PangoEllipsizeMode getEllipsize()
342 	{
343 		return gtk_label_get_ellipsize(gtkLabel);
344 	}
345 
346 	/**
347 	 * Gets the extra menu model of @label.
348 	 *
349 	 * See [method@Gtk.Label.set_extra_menu].
350 	 *
351 	 * Returns: the menu model
352 	 */
353 	public MenuModel getExtraMenu()
354 	{
355 		auto __p = gtk_label_get_extra_menu(gtkLabel);
356 
357 		if(__p is null)
358 		{
359 			return null;
360 		}
361 
362 		return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) __p);
363 	}
364 
365 	/**
366 	 * Returns the justification of the label.
367 	 *
368 	 * See [method@Gtk.Label.set_justify].
369 	 *
370 	 * Returns: `GtkJustification`
371 	 */
372 	public GtkJustification getJustify()
373 	{
374 		return gtk_label_get_justify(gtkLabel);
375 	}
376 
377 	/**
378 	 * Fetches the text from a label.
379 	 *
380 	 * The returned text includes any embedded underlines indicating
381 	 * mnemonics and Pango markup. (See [method@Gtk.Label.get_text]).
382 	 *
383 	 * Returns: the text of the label widget. This string is
384 	 *     owned by the widget and must not be modified or freed.
385 	 */
386 	public string getLabel()
387 	{
388 		return Str.toString(gtk_label_get_label(gtkLabel));
389 	}
390 
391 	/**
392 	 * Gets the `PangoLayout` used to display the label.
393 	 *
394 	 * The layout is useful to e.g. convert text positions to pixel
395 	 * positions, in combination with [method@Gtk.Label.get_layout_offsets].
396 	 * The returned layout is owned by the @label so need not be
397 	 * freed by the caller. The @label is free to recreate its layout
398 	 * at any time, so it should be considered read-only.
399 	 *
400 	 * Returns: the [class@Pango.Layout] for this label
401 	 */
402 	public PgLayout getLayout()
403 	{
404 		auto __p = gtk_label_get_layout(gtkLabel);
405 
406 		if(__p is null)
407 		{
408 			return null;
409 		}
410 
411 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) __p);
412 	}
413 
414 	/**
415 	 * Obtains the coordinates where the label will draw its `PangoLayout`.
416 	 *
417 	 * The coordinates are useful to convert mouse events into coordinates
418 	 * inside the [class@Pango.Layout], e.g. to take some action if some part
419 	 * of the label is clicked. Remember when using the [class@Pango.Layout]
420 	 * functions you need to convert to and from pixels using PANGO_PIXELS()
421 	 * or [const@Pango.SCALE].
422 	 *
423 	 * Params:
424 	 *     x = location to store X offset of layout
425 	 *     y = location to store Y offset of layout
426 	 */
427 	public void getLayoutOffsets(out int x, out int y)
428 	{
429 		gtk_label_get_layout_offsets(gtkLabel, &x, &y);
430 	}
431 
432 	/**
433 	 * Gets the number of lines to which an ellipsized, wrapping
434 	 * label should be limited.
435 	 *
436 	 * See [method@Gtk.Label.set_lines].
437 	 *
438 	 * Returns: The number of lines
439 	 */
440 	public int getLines()
441 	{
442 		return gtk_label_get_lines(gtkLabel);
443 	}
444 
445 	/**
446 	 * Retrieves the desired maximum width of @label, in characters.
447 	 *
448 	 * See [method@Gtk.Label.set_width_chars].
449 	 *
450 	 * Returns: the maximum width of the label in characters.
451 	 */
452 	public int getMaxWidthChars()
453 	{
454 		return gtk_label_get_max_width_chars(gtkLabel);
455 	}
456 
457 	/**
458 	 * Return the mnemonic accelerator.
459 	 *
460 	 * If the label has been set so that it has a mnemonic key this function
461 	 * returns the keyval used for the mnemonic accelerator. If there is no
462 	 * mnemonic set up it returns `GDK_KEY_VoidSymbol`.
463 	 *
464 	 * Returns: GDK keyval usable for accelerators, or `GDK_KEY_VoidSymbol`
465 	 */
466 	public uint getMnemonicKeyval()
467 	{
468 		return gtk_label_get_mnemonic_keyval(gtkLabel);
469 	}
470 
471 	/**
472 	 * Retrieves the target of the mnemonic (keyboard shortcut) of this
473 	 * label.
474 	 *
475 	 * See [method@Gtk.Label.set_mnemonic_widget].
476 	 *
477 	 * Returns: the target of the label’s mnemonic,
478 	 *     or %NULL if none has been set and the default algorithm will be used.
479 	 */
480 	public Widget getMnemonicWidget()
481 	{
482 		auto __p = gtk_label_get_mnemonic_widget(gtkLabel);
483 
484 		if(__p is null)
485 		{
486 			return null;
487 		}
488 
489 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
490 	}
491 
492 	/**
493 	 * Returns line wrap mode used by the label.
494 	 *
495 	 * See [method@Gtk.Label.set_natural_wrap_mode].
496 	 *
497 	 * Returns: the natural line wrap mode
498 	 *
499 	 * Since: 4.6
500 	 */
501 	public GtkNaturalWrapMode getNaturalWrapMode()
502 	{
503 		return gtk_label_get_natural_wrap_mode(gtkLabel);
504 	}
505 
506 	/**
507 	 * Returns whether the label is selectable.
508 	 *
509 	 * Returns: %TRUE if the user can copy text from the label
510 	 */
511 	public bool getSelectable()
512 	{
513 		return gtk_label_get_selectable(gtkLabel) != 0;
514 	}
515 
516 	/**
517 	 * Gets the selected range of characters in the label.
518 	 *
519 	 * Params:
520 	 *     start = return location for start of selection, as a character offset
521 	 *     end = return location for end of selection, as a character offset
522 	 *
523 	 * Returns: %TRUE if selection is non-empty
524 	 */
525 	public bool getSelectionBounds(out int start, out int end)
526 	{
527 		return gtk_label_get_selection_bounds(gtkLabel, &start, &end) != 0;
528 	}
529 
530 	/**
531 	 * Returns whether the label is in single line mode.
532 	 *
533 	 * Returns: %TRUE when the label is in single line mode.
534 	 */
535 	public bool getSingleLineMode()
536 	{
537 		return gtk_label_get_single_line_mode(gtkLabel) != 0;
538 	}
539 
540 	/**
541 	 * Fetches the text from a label.
542 	 *
543 	 * The returned text is as it appears on screen. This does not include
544 	 * any embedded underlines indicating mnemonics or Pango markup. (See
545 	 * [method@Gtk.Label.get_label])
546 	 *
547 	 * Returns: the text in the label widget. This is the internal
548 	 *     string used by the label, and must not be modified.
549 	 */
550 	public string getText()
551 	{
552 		return Str.toString(gtk_label_get_text(gtkLabel));
553 	}
554 
555 	/**
556 	 * Returns whether the label’s text is interpreted as Pango markup.
557 	 *
558 	 * See [method@Gtk.Label.set_use_markup].
559 	 *
560 	 * Returns: %TRUE if the label’s text will be parsed for markup.
561 	 */
562 	public bool getUseMarkup()
563 	{
564 		return gtk_label_get_use_markup(gtkLabel) != 0;
565 	}
566 
567 	/**
568 	 * Returns whether an embedded underlines in the label indicate mnemonics.
569 	 *
570 	 * See [method@Gtk.Label.set_use_underline].
571 	 *
572 	 * Returns: %TRUE whether an embedded underline in the label indicates
573 	 *     the mnemonic accelerator keys.
574 	 */
575 	public bool getUseUnderline()
576 	{
577 		return gtk_label_get_use_underline(gtkLabel) != 0;
578 	}
579 
580 	/**
581 	 * Retrieves the desired width of @label, in characters.
582 	 *
583 	 * See [method@Gtk.Label.set_width_chars].
584 	 *
585 	 * Returns: the width of the label in characters.
586 	 */
587 	public int getWidthChars()
588 	{
589 		return gtk_label_get_width_chars(gtkLabel);
590 	}
591 
592 	/**
593 	 * Returns whether lines in the label are automatically wrapped.
594 	 *
595 	 * See [method@Gtk.Label.set_wrap].
596 	 *
597 	 * Returns: %TRUE if the lines of the label are automatically wrapped.
598 	 */
599 	public bool getWrap()
600 	{
601 		return gtk_label_get_wrap(gtkLabel) != 0;
602 	}
603 
604 	/**
605 	 * Returns line wrap mode used by the label.
606 	 *
607 	 * See [method@Gtk.Label.set_wrap_mode].
608 	 *
609 	 * Returns: the line wrap mode
610 	 */
611 	public PangoWrapMode getWrapMode()
612 	{
613 		return gtk_label_get_wrap_mode(gtkLabel);
614 	}
615 
616 	/**
617 	 * Gets the `xalign` of the label.
618 	 *
619 	 * See the [property@Gtk.Label:xalign] property.
620 	 *
621 	 * Returns: the xalign property
622 	 */
623 	public float getXalign()
624 	{
625 		return gtk_label_get_xalign(gtkLabel);
626 	}
627 
628 	/**
629 	 * Gets the `yalign` of the label.
630 	 *
631 	 * See the [property@Gtk.Label:yalign] property.
632 	 *
633 	 * Returns: the yalign property
634 	 */
635 	public float getYalign()
636 	{
637 		return gtk_label_get_yalign(gtkLabel);
638 	}
639 
640 	/**
641 	 * Selects a range of characters in the label, if the label is selectable.
642 	 *
643 	 * See [method@Gtk.Label.set_selectable]. If the label is not selectable,
644 	 * this function has no effect. If @start_offset or
645 	 * @end_offset are -1, then the end of the label will be substituted.
646 	 *
647 	 * Params:
648 	 *     startOffset = start offset (in characters not bytes)
649 	 *     endOffset = end offset (in characters not bytes)
650 	 */
651 	public void selectRegion(int startOffset, int endOffset)
652 	{
653 		gtk_label_select_region(gtkLabel, startOffset, endOffset);
654 	}
655 
656 	/**
657 	 * Apply attributes to the label text.
658 	 *
659 	 * The attributes set with this function will be applied and merged with
660 	 * any other attributes previously effected by way of the
661 	 * [property@Gtk.Label:use-underline] or [property@Gtk.Label:use-markup]
662 	 * properties. While it is not recommended to mix markup strings with
663 	 * manually set attributes, if you must; know that the attributes will
664 	 * be applied to the label after the markup string is parsed.
665 	 *
666 	 * Params:
667 	 *     attrs = a [struct@Pango.AttrList]
668 	 */
669 	public void setAttributes(PgAttributeList attrs)
670 	{
671 		gtk_label_set_attributes(gtkLabel, (attrs is null) ? null : attrs.getPgAttributeListStruct());
672 	}
673 
674 	/**
675 	 * Sets the mode used to ellipsizei the text.
676 	 *
677 	 * The text will be ellipsized if there is not enough space
678 	 * to render the entire string.
679 	 *
680 	 * Params:
681 	 *     mode = a `PangoEllipsizeMode`
682 	 */
683 	public void setEllipsize(PangoEllipsizeMode mode)
684 	{
685 		gtk_label_set_ellipsize(gtkLabel, mode);
686 	}
687 
688 	/**
689 	 * Sets a menu model to add when constructing
690 	 * the context menu for @label.
691 	 *
692 	 * Params:
693 	 *     model = a `GMenuModel`
694 	 */
695 	public void setExtraMenu(MenuModel model)
696 	{
697 		gtk_label_set_extra_menu(gtkLabel, (model is null) ? null : model.getMenuModelStruct());
698 	}
699 
700 	/**
701 	 * Sets the alignment of the lines in the text of the label relative to
702 	 * each other.
703 	 *
704 	 * %GTK_JUSTIFY_LEFT is the default value when the widget is first created
705 	 * with [ctor@Gtk.Label.new]. If you instead want to set the alignment of
706 	 * the label as a whole, use [method@Gtk.Widget.set_halign] instead.
707 	 * [method@Gtk.Label.set_justify] has no effect on labels containing
708 	 * only a single line.
709 	 *
710 	 * Params:
711 	 *     jtype = a `GtkJustification`
712 	 */
713 	public void setJustify(GtkJustification jtype)
714 	{
715 		gtk_label_set_justify(gtkLabel, jtype);
716 	}
717 
718 	/**
719 	 * Sets the text of the label.
720 	 *
721 	 * The label is interpreted as including embedded underlines and/or Pango
722 	 * markup depending on the values of the [property@Gtk.Label:use-underline]
723 	 * and [property@Gtk.Label:use-markup] properties.
724 	 *
725 	 * Params:
726 	 *     str = the new text to set for the label
727 	 */
728 	public void setLabel(string str)
729 	{
730 		gtk_label_set_label(gtkLabel, Str.toStringz(str));
731 	}
732 
733 	/**
734 	 * Sets the number of lines to which an ellipsized, wrapping label
735 	 * should be limited.
736 	 *
737 	 * This has no effect if the label is not wrapping or ellipsized.
738 	 * Set this to -1 if you don’t want to limit the number of lines.
739 	 *
740 	 * Params:
741 	 *     lines = the desired number of lines, or -1
742 	 */
743 	public void setLines(int lines)
744 	{
745 		gtk_label_set_lines(gtkLabel, lines);
746 	}
747 
748 	/**
749 	 * Sets the labels text and attributes from markup.
750 	 *
751 	 * The string must be marked up with Pango markup
752 	 * (see [func@Pango.parse_markup]).
753 	 *
754 	 * If the @str is external data, you may need to escape it
755 	 * with g_markup_escape_text() or g_markup_printf_escaped():
756 	 *
757 	 * ```c
758 	 * GtkWidget *self = gtk_label_new (NULL);
759 	 * const char *str = "...";
760 	 * const char *format = "<span style=\"italic\">\%s</span>";
761 	 * char *markup;
762 	 *
763 	 * markup = g_markup_printf_escaped (format, str);
764 	 * gtk_label_set_markup (GTK_LABEL (self), markup);
765 	 * g_free (markup);
766 	 * ```
767 	 *
768 	 * This function will set the [property@Gtk.Label:use-markup] property
769 	 * to %TRUE as a side effect.
770 	 *
771 	 * If you set the label contents using the [property@Gtk.Label:label]
772 	 * property you should also ensure that you set the
773 	 * [property@Gtk.Label:use-markup] property accordingly.
774 	 *
775 	 * See also: [method@Gtk.Label.set_text]
776 	 *
777 	 * Params:
778 	 *     str = a markup string
779 	 */
780 	public void setMarkup(string str)
781 	{
782 		gtk_label_set_markup(gtkLabel, Str.toStringz(str));
783 	}
784 
785 	/**
786 	 * Sets the labels text, attributes and mnemonic from markup.
787 	 *
788 	 * Parses @str which is marked up with Pango markup (see [func@Pango.parse_markup]),
789 	 * setting the label’s text and attribute list based on the parse results.
790 	 * If characters in @str are preceded by an underscore, they are underlined
791 	 * indicating that they represent a keyboard accelerator called a mnemonic.
792 	 *
793 	 * The mnemonic key can be used to activate another widget, chosen
794 	 * automatically, or explicitly using [method@Gtk.Label.set_mnemonic_widget].
795 	 *
796 	 * Params:
797 	 *     str = a markup string
798 	 */
799 	public void setMarkupWithMnemonic(string str)
800 	{
801 		gtk_label_set_markup_with_mnemonic(gtkLabel, Str.toStringz(str));
802 	}
803 
804 	/**
805 	 * Sets the desired maximum width in characters of @label to @n_chars.
806 	 *
807 	 * Params:
808 	 *     nChars = the new desired maximum width, in characters.
809 	 */
810 	public void setMaxWidthChars(int nChars)
811 	{
812 		gtk_label_set_max_width_chars(gtkLabel, nChars);
813 	}
814 
815 	/**
816 	 * Associate the label with its mnemonic target.
817 	 *
818 	 * If the label has been set so that it has a mnemonic key (using
819 	 * i.e. [method@Gtk.Label.set_markup_with_mnemonic],
820 	 * [method@Gtk.Label.set_text_with_mnemonic],
821 	 * [ctor@Gtk.Label.new_with_mnemonic]
822 	 * or the [property@Gtk.Label:use_underline] property) the label can be
823 	 * associated with a widget that is the target of the mnemonic. When the
824 	 * label is inside a widget (like a [class@Gtk.Button] or a
825 	 * [class@Gtk.Notebook] tab) it is automatically associated with the correct
826 	 * widget, but sometimes (i.e. when the target is a [class@Gtk.Entry] next to
827 	 * the label) you need to set it explicitly using this function.
828 	 *
829 	 * The target widget will be accelerated by emitting the
830 	 * [signal@GtkWidget::mnemonic-activate] signal on it. The default handler for
831 	 * this signal will activate the widget if there are no mnemonic collisions
832 	 * and toggle focus between the colliding widgets otherwise.
833 	 *
834 	 * Params:
835 	 *     widget = the target `GtkWidget`, or %NULL to unset
836 	 */
837 	public void setMnemonicWidget(Widget widget)
838 	{
839 		gtk_label_set_mnemonic_widget(gtkLabel, (widget is null) ? null : widget.getWidgetStruct());
840 	}
841 
842 	/**
843 	 * Select the line wrapping for the natural size request.
844 	 *
845 	 * This only affects the natural size requested, for the actual wrapping used,
846 	 * see the [property@Gtk.Label:wrap-mode] property.
847 	 *
848 	 * Params:
849 	 *     wrapMode = the line wrapping mode
850 	 *
851 	 * Since: 4.6
852 	 */
853 	public void setNaturalWrapMode(GtkNaturalWrapMode wrapMode)
854 	{
855 		gtk_label_set_natural_wrap_mode(gtkLabel, wrapMode);
856 	}
857 
858 	/**
859 	 * Makes text in the label selectable.
860 	 *
861 	 * Selectable labels allow the user to select text from the label,
862 	 * for copy-and-paste.
863 	 *
864 	 * Params:
865 	 *     setting = %TRUE to allow selecting text in the label
866 	 */
867 	public void setSelectable(bool setting)
868 	{
869 		gtk_label_set_selectable(gtkLabel, setting);
870 	}
871 
872 	/**
873 	 * Sets whether the label is in single line mode.
874 	 *
875 	 * Params:
876 	 *     singleLineMode = %TRUE if the label should be in single line mode
877 	 */
878 	public void setSingleLineMode(bool singleLineMode)
879 	{
880 		gtk_label_set_single_line_mode(gtkLabel, singleLineMode);
881 	}
882 
883 	/**
884 	 * Sets the text within the `GtkLabel` widget.
885 	 *
886 	 * It overwrites any text that was there before.
887 	 *
888 	 * This function will clear any previously set mnemonic accelerators,
889 	 * and set the [property@Gtk.Label:use-underline property] to %FALSE as
890 	 * a side effect.
891 	 *
892 	 * This function will set the [property@Gtk.Label:use-markup] property
893 	 * to %FALSE as a side effect.
894 	 *
895 	 * See also: [method@Gtk.Label.set_markup]
896 	 *
897 	 * Params:
898 	 *     str = The text you want to set
899 	 */
900 	public void setText(string str)
901 	{
902 		gtk_label_set_text(gtkLabel, Str.toStringz(str));
903 	}
904 
905 	/**
906 	 * Sets the label’s text from the string @str.
907 	 *
908 	 * If characters in @str are preceded by an underscore, they are underlined
909 	 * indicating that they represent a keyboard accelerator called a mnemonic.
910 	 * The mnemonic key can be used to activate another widget, chosen
911 	 * automatically, or explicitly using [method@Gtk.Label.set_mnemonic_widget].
912 	 *
913 	 * Params:
914 	 *     str = a string
915 	 */
916 	public void setTextWithMnemonic(string str)
917 	{
918 		gtk_label_set_text_with_mnemonic(gtkLabel, Str.toStringz(str));
919 	}
920 
921 	/**
922 	 * Sets whether the text of the label contains markup.
923 	 *
924 	 * See [method@Gtk.Label.set_markup].
925 	 *
926 	 * Params:
927 	 *     setting = %TRUE if the label’s text should be parsed for markup.
928 	 */
929 	public void setUseMarkup(bool setting)
930 	{
931 		gtk_label_set_use_markup(gtkLabel, setting);
932 	}
933 
934 	/**
935 	 * Sets whether underlines in the text indicate mnemonics.
936 	 *
937 	 * Params:
938 	 *     setting = %TRUE if underlines in the text indicate mnemonics
939 	 */
940 	public void setUseUnderline(bool setting)
941 	{
942 		gtk_label_set_use_underline(gtkLabel, setting);
943 	}
944 
945 	/**
946 	 * Sets the desired width in characters of @label to @n_chars.
947 	 *
948 	 * Params:
949 	 *     nChars = the new desired width, in characters.
950 	 */
951 	public void setWidthChars(int nChars)
952 	{
953 		gtk_label_set_width_chars(gtkLabel, nChars);
954 	}
955 
956 	/**
957 	 * Toggles line wrapping within the `GtkLabel` widget.
958 	 *
959 	 * %TRUE makes it break lines if text exceeds the widget’s size.
960 	 * %FALSE lets the text get cut off by the edge of the widget if
961 	 * it exceeds the widget size.
962 	 *
963 	 * Note that setting line wrapping to %TRUE does not make the label
964 	 * wrap at its parent container’s width, because GTK widgets
965 	 * conceptually can’t make their requisition depend on the parent
966 	 * container’s size. For a label that wraps at a specific position,
967 	 * set the label’s width using [method@Gtk.Widget.set_size_request].
968 	 *
969 	 * Params:
970 	 *     wrap = the setting
971 	 */
972 	public void setWrap(bool wrap)
973 	{
974 		gtk_label_set_wrap(gtkLabel, wrap);
975 	}
976 
977 	/**
978 	 * Controls how line wrapping is done.
979 	 *
980 	 * This only affects the label if line wrapping is on. (See
981 	 * [method@Gtk.Label.set_wrap]) The default is %PANGO_WRAP_WORD
982 	 * which means wrap on word boundaries.
983 	 *
984 	 * For sizing behavior, also consider the [property@Gtk.Label:natural-wrap-mode]
985 	 * property.
986 	 *
987 	 * Params:
988 	 *     wrapMode = the line wrapping mode
989 	 */
990 	public void setWrapMode(PangoWrapMode wrapMode)
991 	{
992 		gtk_label_set_wrap_mode(gtkLabel, wrapMode);
993 	}
994 
995 	/**
996 	 * Sets the `xalign` of the label.
997 	 *
998 	 * See the [property@Gtk.Label:xalign] property.
999 	 *
1000 	 * Params:
1001 	 *     xalign = the new xalign value, between 0 and 1
1002 	 */
1003 	public void setXalign(float xalign)
1004 	{
1005 		gtk_label_set_xalign(gtkLabel, xalign);
1006 	}
1007 
1008 	/**
1009 	 * Sets the `yalign` of the label.
1010 	 *
1011 	 * See the [property@Gtk.Label:yalign] property.
1012 	 *
1013 	 * Params:
1014 	 *     yalign = the new yalign value, between 0 and 1
1015 	 */
1016 	public void setYalign(float yalign)
1017 	{
1018 		gtk_label_set_yalign(gtkLabel, yalign);
1019 	}
1020 
1021 	/**
1022 	 * Gets emitted when the user activates a link in the label.
1023 	 *
1024 	 * The ::activate-current-link is a [keybinding signal](class.SignalAction.html).
1025 	 *
1026 	 * Applications may also emit the signal with g_signal_emit_by_name()
1027 	 * if they need to control activation of URIs programmatically.
1028 	 *
1029 	 * The default bindings for this signal are all forms of the Enter key.
1030 	 */
1031 	gulong addOnActivateCurrentLink(void delegate(Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1032 	{
1033 		return Signals.connect(this, "activate-current-link", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1034 	}
1035 
1036 	/**
1037 	 * Gets emitted to activate a URI.
1038 	 *
1039 	 * Applications may connect to it to override the default behaviour,
1040 	 * which is to call gtk_show_uri().
1041 	 *
1042 	 * Params:
1043 	 *     uri = the URI that is activated
1044 	 *
1045 	 * Returns: %TRUE if the link has been activated
1046 	 */
1047 	gulong addOnActivateLink(bool delegate(string, Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1048 	{
1049 		return Signals.connect(this, "activate-link", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1050 	}
1051 
1052 	/**
1053 	 * Gets emitted to copy the slection to the clipboard.
1054 	 *
1055 	 * The ::copy-clipboard signal is a [keybinding signal](class.SignalAction.html).
1056 	 *
1057 	 * The default binding for this signal is Ctrl-c.
1058 	 */
1059 	gulong addOnCopyClipboard(void delegate(Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1060 	{
1061 		return Signals.connect(this, "copy-clipboard", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1062 	}
1063 
1064 	/**
1065 	 * Gets emitted when the user initiates a cursor movement.
1066 	 *
1067 	 * The ::move-cursor signal is a [keybinding signal](class.SignalAction.html).
1068 	 * If the cursor is not visible in @entry, this signal causes the viewport to
1069 	 * be moved instead.
1070 	 *
1071 	 * Applications should not connect to it, but may emit it with
1072 	 * g_signal_emit_by_name() if they need to control the cursor
1073 	 * programmatically.
1074 	 *
1075 	 * The default bindings for this signal come in two variants,
1076 	 * the variant with the Shift modifier extends the selection,
1077 	 * the variant without the Shift modifier does not.
1078 	 * There are too many key combinations to list them all here.
1079 	 * - Arrow keys move by individual characters/lines
1080 	 * - Ctrl-arrow key combinations move by words/paragraphs
1081 	 * - Home/End keys move to the ends of the buffer
1082 	 *
1083 	 * Params:
1084 	 *     step = the granularity of the move, as a `GtkMovementStep`
1085 	 *     count = the number of @step units to move
1086 	 *     extendSelection = %TRUE if the move should extend the selection
1087 	 */
1088 	gulong addOnMoveCursor(void delegate(GtkMovementStep, int, bool, Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1089 	{
1090 		return Signals.connect(this, "move-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1091 	}
1092 }